package com.le.tester.book.flightjava8.stream;

import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.stream.Stream;

/**
 * createTime：2025-07-23 15:35
 * description：创建流
 */
public class Create {
    public static void main(String[] args) {
        Stream<String> stream = Stream.of("java 8", "lambdas", "in", "action");
        stream.map(String::toUpperCase).forEach(System.out::println);

        long uniqueWords = 0;
        try (Stream<String> lines = Files.lines(Paths.get("data.txt"), Charset.defaultCharset())) {
            lines.flatMap(item -> Arrays.stream(item.split(" ")))
                    .distinct()
                    .count();

        } catch (Exception e) {

        }
    }
}
